<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.css" rel="stylesheet" />
		<link href="css/change_password.css" rel="stylesheet" />
	</head>

	<body>
		<script src="js/mui.js"></script>
		<script type="text/javascript">
			mui.init()
		</script>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">修改密码🔒</h1>
		</header>
		<div class="mui-content">
			<div class="s1">
				<div class="s2">
					
				</div>
			</div>
			<div class="password_list">
				<input type="password" name="" class="password" placeholder="原密码" id="password"/>
				<input type="password" name="" class="password" placeholder="新密码" id="password1"/>
				<input type="button" name=""  value="修改" class="commit"/>
			</div>
		</div>
		
		<script type="text/javascript">
			mui.plusReady(function () {
			    document.getElementsByClassName('commit')[0].addEventListener('tap',function(){
					var pass_re = /[a-zA-Z][a-zA-Z.0-9]{5,15}/
					var password = document.getElementById('password').value
					var password1 = document.getElementById('password1').value
					if(password == null | password1 == null | password.length <6 | password1<6 | !pass_re.test(password) | !pass_re.test(password1)){
						mui.toast('小主密码不符合规范哦~')
						return
					}
					if(password == password1){
						mui.toast('小主,两次密码一致哦~')
						return
					}
					mui.ajax(localStorage.getItem('request_url')+ "cost/user/update_password/?token="+localStorage.getItem('uid'), {
					    data:"token=" + localStorage.getItem('uid') +'&password=' + password + '&password1=' + password1,
					    dataType:'json',  
					    type:'POST',  
					    contentType:"application/x-www-form-urlencoded; charset=utf-8",  
					    timeout:2000,  
					    success:function show(e){
							mui.toast('😃更新完成...');
							mui.back()
						},  
					    error:function(xhr,type,errorThrown){
							
							var data = JSON.parse(xhr.responseText)
							// mui.toast(data.data.username);
							if(data.code==0){
								mui.toast('修改失败，错误请求')
							}else{
								mui.toast(data.msg)
								mui.toast(data.data.rule,{ duration:'long'})
							}
					    }  
					});
				})
			})
		</script>
		
	</body>

</html>
